/**
 * Created by XiaAo on 2017/5/5.
 */


var memberAdminModule = require('../../ngModule/ngModuleAdmin');//请求书籍管理Module

memberAdminModule.controller('memberAdminCtrl',['$rootScope','$scope','$state','$http',function ($rootScope, $scope,$state,$http) {

    $rootScope.itemLibHightFocus = ['', 'left-Bar-High-Focus', '', '','',''];//导航栏高亮显示

    console.log('执行到memberAdminCtrl');

    //显示成员list，隐藏其他
    $scope.memberAdminDisplay=function () {
        $('#member-admin-detail').css('display','none');
        $('#member-admin-add').css('display','none');
        $('#member-admin-modify').css('display','none');
        $('#member-admin-list').css('display','block');
    };
    //显示add成员，隐藏其他
    $scope.addDisplay=function () {
        $('#member-admin-detail').css('display','none');
        $('#member-admin-modify').css('display','none');
        $('#member-admin-add').css('display','block');
        $('#member-admin-list').css('display','none');
    };

    //显示modify成员，隐藏其他
    $scope.modifyDisplay=function (arr) {
        $scope.infoList = arr;
        $('#member-admin-detail').css('display','none');
        $('#member-admin-add').css('display','none');
        $('#member-admin-modify').css('display','block');
        $('#member-admin-list').css('display','none');
    };

    //显示modify成员，隐藏其他
    $scope.delete=function (arr) {
        $scope.infoBasic = arr;
        console.log($scope.infoBasic);
    };


    $scope.detailDisplay = function (arr) {
        $scope.infoList = arr;
        // $scope.$$childTail.studentCtrl.List = arr;
        // $scope.$broadcast('to-child', arr);

        console.log(arr);
        console.log($scope.infoList);
        //显示成员详情，隐藏其他
        $('#member-admin-detail').css('display','block');
        $('#member-admin-add').css('display','none');
        $('#member-admin-modify').css('display','none');
        $('#member-admin-list').css('display','none');

    };

    $http({
        method: 'POST',
        url: '../showstudents/QueryAllStudentsAction.action'
        // catch:true,
    }).
    then(function(data, status, headers, config) {
        console.log('data请求成功------');

        console.log(data);
        $scope.items = JSON.parse(data.data)[0].data;
        console.log('====');
        console.log($scope.items[0].sName);
    }).
    catch(function(data, status, headers, config) {
        console.log('data请求失败------');
        console.error();
    });

    /**
    * 添加内容时，新插入一条，向父元素里面插入一个新的元素
    * */
    $scope.newline=function ($event) {

        var input=document.createElement("INPUT");
        input.setAttribute("class","form-control");
        // var input="<input id="+"addPaper"+" class="+"form-control"+" />";

        // document.getElementById("addPaper").appendChild(input);
        console.log($event.target);
        $event.target.parentNode.parentNode.appendChild(input);

        // $('#addPaper').appendChild(input);
        console.log(666);
    }


}]);

